import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: Anastasia
 * Date: 15.12.14
 * Time: 23:04
 * To change this template use File | Settings | File Templates.
 */
public class Department implements Serializable {

    private String name;
    private Employee employee;

    public Department()
    {
        name=null;
        employee=null;
    }

    public Department(String name, Employee emp)
    {
        this.name = name;
        this.employee = emp;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setEmployee(Employee emp) {
        employee = emp;
    }

    public Employee getEmployee() {
        return employee;
    }

    public String getInfo()
    {
        if(this.getEmployee()!=null)
        {
            return new String(name+ ". Начальник: " +employee.getName()+" "+ employee.getLastName() );
        }
        else  return new String(name+ ". ,без начальника " );
    }

    public boolean equals(Department d1)
    {
        if ((this.getEmployee()==null&&d1.getEmployee()==null)&&this.getName().equals(d1.getName()))
        {
            return true;
        }
        else
        {
            if(this.getEmployee()!=null&&d1.getEmployee()!=null)
            {
                if(this.getEmployee().getName().equals(d1.getEmployee().getName())&&this.getEmployee().getSurname().equals(d1.getEmployee().getSurname())&&this.getEmployee().getLastName().equals(d1.getEmployee().getLastName())&&this.getName().equals(d1.getName()))
                {return true;}
                else {return false;}
            }
            else{return false;}
        }
    }
}
